package com.example.service.impl;

import com.example.service.TPService;
import org.apache.dubbo.config.annotation.Service;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * @author zhouyp
 * @program tp-monitor
 * @description
 * @create 2020-07-09
 */
@Service
public class TPServiceImpl implements TPService {
	private final Random random = new Random();

	@Override
	public void methodA() throws InterruptedException {
		long mill = getRandomMill();
		TimeUnit.MILLISECONDS.sleep(mill);
		System.out.println("methodA need sleep:[{" + mill + "}]milliseconds");
	}

	@Override
	public void methodB() throws InterruptedException {
		long mill = getRandomMill();
		TimeUnit.MILLISECONDS.sleep(mill);
		System.out.println("methodB need sleep:[{" + mill + "}]milliseconds");
	}

	@Override
	public void methodC() throws InterruptedException {
		long mill = getRandomMill();
		TimeUnit.MILLISECONDS.sleep(mill);
		System.out.println("methodC need sleep:[{" + mill + "}]milliseconds");
	}

	private long getRandomMill() {
		return random.nextInt(100);
	}
}
